package com.ccxe.manage.dao.impl;

import java.sql.ResultSet;

import com.ccxe.manage.dao.LoginDAO;
import com.ccxe.manage.db.CcxDB;
import com.ccxe.manage.db.CcxDBCommon;
import com.ccxe.manage.db.DBFactory;


public class NomalUserLoginDaoImpl extends CcxDBCommon implements LoginDAO {


	public NomalUserLoginDaoImpl() throws Exception {
		super();
	}
	
	public boolean getLogin(String user ,String pass) {
		CcxDB ccxDB = null;
		ResultSet rs = null;
		String userPassword = null;
		try {
			if (user != null && !pass.equals("")) {
				String sqlKey = "select PASSWORD from C_USER_PASSWORD where USER_ID=?";
				Object[] items = new Object[1];
				items[0] = user;
				ccxDB = DBFactory.getInstance();
				rs = ccxDB.executeQuery(sqlKey, items);
				if (rs.next()) {
					userPassword = rs.getString("PASSWORD");
				}
				if(pass.equals(userPassword))
					return true;
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (ccxDB != null)
					ccxDB.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return false;
	}

	@Override
	public long getNextAddressNumber() throws Exception {
		return 0;
	}

	@Override
	public long getNextMsgNumber() throws Exception {
		return 0;
	}

}